home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / lang / Python16_Src.lha / Python16_Source / Include / intobject.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-03  |  2.3 KB  |  68 lines

  1. #ifndef Py_INTOBJECT_H
  2. #define Py_INTOBJECT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7. /* Integer object interface */
  8.  
  9. /*
  10. PyIntObject represents a (long) integer.  This is an immutable object;
  11. an integer cannot change its value after creation.
  12.  
  13. There are functions to create new integer objects, to test an object
  14. for integer-ness, and to get the integer value.  The latter functions
  15. returns -1 and sets errno to EBADF if the object is not an PyIntObject.
  16. None of the functions should be applied to nil objects.
  17.  
  18. The type PyIntObject is (unfortunately) exposed here so we can declare
  19. _Py_TrueStruct and _Py_ZeroStruct below; don't use this.
  20. */
  21.  
  22. typedef struct {
  23.     PyObject_HEAD
  24.     long ob_ival;
  25. } PyIntObject;
  26.  
  27. extern DL_IMPORT(PyTypeObject) PyInt_Type;
  28.  
  29. #define PyInt_Check(op) ((op)->ob_type == &PyInt_Type)
  30.  
  31. extern DL_IMPORT(PyObject *) PyInt_FromString Py_PROTO((char*, char**, int));
  32. extern DL_IMPORT(PyObject *) PyInt_FromUnicode Py_PROTO((Py_UNICODE*, int, int));
  33. extern DL_IMPORT(PyObject *) PyInt_FromLong Py_PROTO((long));
  34. extern DL_IMPORT(long) PyInt_AsLong Py_PROTO((PyObject *));
  35. extern DL_IMPORT(long) PyInt_GetMax Py_PROTO((void));
  36.  
  37.  
  38. /*
  39. False and True are special intobjects used by Boolean expressions.
  40. All values of type Boolean must point to either of these; but in
  41. contexts where integers are required they are integers (valued 0 and 1).
  42. Hope these macros don't conflict with other people's.
  43.  
  44. Don't forget to apply Py_INCREF() when returning True or False!!!
  45. */
  46.  
  47. extern DL_IMPORT(PyIntObject) _Py_ZeroStruct, _Py_TrueStruct; /* Don't use these directly */
  48.  
  49. #define Py_False ((PyObject *) &_Py_ZeroStruct)
  50. #define Py_True ((PyObject *) &_Py_TrueStruct)
  51.  
  52. /* Macro, trading safety for speed */
  53. #define PyInt_AS_LONG(op) (((PyIntObject *)(op))->ob_ival)
  54.  
  55. /* These aren't really part of the Int object, but they're handy; the protos
  56.  * are necessary for systems that need the magic of DL_IMPORT and that want
  57.  * to have stropmodule as a dynamically loaded module instead of building it
  58.  * into the main Python shared library/DLL.  Guido thinks I'm weird for
  59.  * building it this way.  :-)  [cjh]
  60.  */
  61. extern DL_IMPORT(unsigned long) PyOS_strtoul Py_PROTO((char *, char **, int));
  62. extern DL_IMPORT(long) PyOS_strtol Py_PROTO((char *, char **, int));
  63.  
  64. #ifdef __cplusplus
  65. }
  66. #endif
  67. #endif /* !Py_INTOBJECT_H */
  68.